home *** CD-ROM | disk | FTP | other *** search
/ Sun Solutions 1997 April to September / Sun Solutions CD - APR '97 - SEP '97 (704-3778-12 Rev. H)(Sun Microsystems, Inc.)(1997).iso / products / bin / httpd / Solaris_2 / addshow.pl < prev    next >
Perl Script  |  1996-06-07  |  17KB  |  542 lines

  1. #!./perl
  2.  
  3. # ------------------------------------------------------------
  4.  
  5. # addshow.pl, by Jean-Pierre Girard (jpg@corrado.sun.com)
  6. # This helps the user to insert a slide-show or a demo of
  7. # its product in the cdware
  8.  
  9. # ------------------------------------------------------------
  10.  
  11. # Bugs and other fixes
  12.  
  13. # ------------------------------------------------------------
  14. %DefaultShellnames = (
  15. "DEMO", "install_show.sh",
  16. "TESTDRIVE", "run.sh",
  17. "INSTALL", "install.sh",
  18. );
  19.  
  20. %DefaultFilenames = (
  21. "DEMO", "show",
  22. "TESTDRIVE", "run",
  23. "INSTALL", "install",
  24. );
  25.  
  26. %WindowTitle = (
  27. "DEMO", "Run Presentation",
  28. "TESTDRIVE", "Run Trial Software",
  29. "INSTALL", "Install Trial Software",
  30. );
  31. #############################################################################
  32. # CreateFiles: create the shell scripts
  33. #############################################################################
  34. sub CreateFiles
  35. {
  36.     local($old);
  37.     #print "bef open: request = $request<br>";
  38.     %rqpairs = split(/[&=]/, $request);
  39.     $request =~ s/^(TESTDRIVE|DEMO|INSTALL).*/\1/;
  40.     $ShellFile = "$InstallDir/$DefaultShellnames{$request}";
  41.     $ScriptFile = "$InstallDir/$rqpairs{$request}";
  42.     #print "bef open: request = $request.<br>";
  43.     if (open(SHELL_FILE, ">$ShellFile") || !&PrintErr("NoCreation", $ShellFile)) {
  44.         write SHELL_FILE;
  45.  
  46.         close (SHELL_FILE);
  47.         chmod (0777, $ShellFile);
  48.         if ($rqpairs{"CreateDefault"} eq "yes" ) {
  49.             if (open(SCRIPT_FILE, ">$ScriptFile") || !&PrintErr("NoCreation", $ScriptFile)) {
  50.                 #print "after open $ScriptFile<br>";
  51.                 $old = select(SCRIPT_FILE);
  52.                 #print STDOUT "bef if<br>";
  53.                 if ($request eq "TESTDRIVE") {
  54.                     #print STDOUT "after testdr $ScriptFile<br>";
  55.                     $~ = "DEFAULT_SHOW_SCRIPT";
  56.                 } elsif ($request eq "INSTALL") {
  57.                     #print STDOUT "after install $ScriptFile<br>";
  58.                     $~ = "DEFAULT_INST_SCRIPT";
  59.                 } elsif ($request eq "DEMO") {
  60.                     #print STDOUT "after demo $ScriptFile<br>";
  61.                     $~ = "DEFAULT_RUN_SCRIPT";
  62.                 }
  63.                 #print STDOUT "bef if<br>";
  64.                 write SCRIPT_FILE;
  65.                 #print STDOUT "bef close<br>";
  66.                 close(SCRIPT_FILE);
  67.                 chmod (0777, $ScriptFile);
  68.                 #print STDOUT "bef sel<br>";
  69.                 select($old);
  70.                 #print STDOUT "after sel<br>";
  71.                 #system("textedit $ScriptFile&");
  72.                 #print "bef textedit $ScriptFile, <br>BASEDIR=$BASEDIR<br>";
  73.                 #print `/usr/openwin/bin/textedit $ScriptFile`;
  74.                 #print `/usr/openwin/bin/textedit $ScriptFile&`;
  75.                 #print `pwd; echo "<br>"; hostname;echo "<br>";xhost +; id`;
  76.                 #$HostName = `hostname`;
  77.                 #print `(xhost +$HostName;$BASEDIR/DEV/bin/textedit.sh $ScriptFile) >/home/jpg/.products/.bin/httpd/Solaris_2/jpg4`;
  78.                 #print `$BASEDIR/DEV/bin/textedit.sh $ScriptFile >/home/jpg/.products/.bin/httpd/Solaris_2/jpg4`;
  79.             }
  80.         }
  81.         $request = "";
  82.     }
  83. }
  84.  
  85. #############################################################################
  86. # AskFileName: Ask for the name of the script
  87. #############################################################################
  88. sub OffersEditScript
  89. {
  90.     #print "In Offer=$_[0]<br>";
  91.     $ScriptName = "$InstallDir/$DefaultShellnames{$_[0]}";
  92.     #print "ScriptName=$ScriptName.<br>";
  93.     if (-s $ScriptName && open (SCRIPTFILE, $ScriptName)) {
  94.         $CustName = "";
  95.         while (<SCRIPTFILE>) {
  96.             #print "$_<br>";
  97.             if ($_ =~ /\/_install\//) {
  98.                 #print "found=$_<br>";
  99.                 $CustName = $_;
  100.                 $CustName =~ s#.*/([^/ ]*) *\n$#\1#;
  101.                 last;
  102.             }
  103.         }
  104.         #$CustName = "$InstallDir/$CustName";
  105.         #print "CustName=$CustName.<br>";
  106.         if (-s "$InstallDir/$CustName") {
  107.             print "<ul>";
  108.             print "<IMG src=\"http://localhost:5759/DEV/images/bullet_ball_green.gif\"><a href=\"http://localhost:5759/cgi-bin/addshow.pl?textedit=$InstallDir/$CustName\">To edit the lauching script of your product</a><br>";
  109.             $ScriptName =~ s?.*/([^/]*/_install/[^/]*)$?\1?;
  110.             print "<IMG src=\"http://localhost:5759/DEV/images/bullet_ball_green.gif\"><a href=\"http://localhost:5759/$ScriptName\">To test your script</a><br>";
  111.             print "</ul>";
  112.         } else {
  113.             print "<ul><h4><applet class=\"ImageLoopItem\" img=\"http://localhost:5759/DEV/images/blinkingAlert\" ALIGN=middle pause=0 width=56 height=49 pause = 200>You need to create a script called \"$CustName\"</h4></ul>";
  114.             #print "<ul><h4><applet class=\"ImageLoopItem\" img=\"http://localhost:5759/DEV/images/blinkingAlert\" ALIGN=middle pause=0 width=56 height=49 pause = 200>You need to create a script called \"$CustName\"</h4></ul>";
  115.         }
  116.     } else {
  117.         print "<ul><h4><applet class=\"ImageLoopItem\" img=\"http://localhost:5759/DEV/images/blinkingAlert\" ALIGN=middle pause=0 width=56 height=49 pause = 200>You need to select the previous link to create your scripts</h4></ul>";
  118.         #print "<ul><h4><IMG ALIGN=middle SRC=\"http://localhost:5759/DEV/images/finger.gif\">You need to select the previous link to create your scripts</h4></ul>";
  119.     }
  120. }
  121.  
  122. #############################################################################
  123. # AskFileName: Ask for the name of the script
  124. #############################################################################
  125. sub AskFileName
  126. {
  127.     print "<h2><IMG ALIGN=middle SRC=\"http://localhost:5759/DEV/images/finger.gif\" >Read this:</h2><p>You need to specify the name of your script that will do the job. If you don't already have one, select \"Create a default script\". This will create a default script that you can edit later to fit your needs.<br>"
  128.         ,"<p>Enter the filename of your script:"
  129.         , "<FORM method=\"post\"  ACTION=\"http://localhost:5759/cgi-bin/addshow.pl?$_[0]\"> <INPUT TYPE=\"text\" value=\""
  130.         , $DefaultFilenames{$_[0]}
  131.         , "\" NAME=\"$_[0]\" SIZE=\"20\" MAXLENGTH=50></p>"
  132.         , "<p><input type=\"checkbox\" NAME=\"CreateDefault\" VALUE=\"yes\">Create a default script <br>"
  133.         , "<center><input type=\"submit\" VALUE=\"Create File\" ></center></FORM>";
  134.     $~ = FOOTER;
  135.     write;
  136. }
  137.  
  138. #############################################################################
  139. # main
  140. #############################################################################
  141. $BASEDIR = $ENV{"DOCUMENT_ROOT"};
  142. require 'devinfo.pl';
  143. require 'tools.pl';
  144.  
  145. $HomeDir = &GetDevinfo("dir");
  146. $ShortHomeDir = $HomeDir;
  147. $ShortHomeDir =~ s?.*/([^/]*)$?\1?;
  148.  
  149. $InstallDir = "$HomeDir/_install";
  150. $INFOFILENAME = $HomeDir . "/_info";
  151.  
  152. if (-s $INFOFILENAME && open (INFOFILE, $INFOFILENAME)) {
  153.     $LINE=<INFOFILE>;
  154.     ($Company, $Description, $Platform) = split(/\^/, $LINE);
  155.     close (INFOFILE);
  156. }
  157. if ($ENV{'REQUEST_METHOD'} eq "POST") {
  158.     read(STDIN, $request, $ENV{'CONTENT_LENGTH'});
  159. } elsif ($ENV{'REQUEST_METHOD'} eq "GET" ) {
  160.     $request = $ENV{'QUERY_STRING'};
  161. }
  162.  
  163. $~ = HEADER;
  164. write;
  165.  
  166. #system ("$BASEDIR/DEV/bin/textedit.sh \"TEST\" >/home/jpg/DEV/.products/.bin/httpd/Solaris_2/jpg4");
  167. #print "ShortHomeDir = $ShortHomeDir<br>";
  168. #print "request=$request<br>";
  169. $request =~ s/%(..)/pack("c",hex($1))/ge;
  170. #print "request=$request<br>";
  171. #print "ARGV0=$ARGV[0]<br>";
  172.  
  173. #if (@ARGV == 0 && $request eq "") {
  174.  
  175. #    #print "in case argv=0";
  176. #} elsif ($request eq "default=Create") {
  177. #    #print "bef CreateDefault<br>";
  178. #} else {
  179. #}
  180.  
  181. if ($request ne "") {
  182.     #print "not null request=$request.<br>";
  183.     unless (-d $InstallDir) {
  184.         mkdir($InstallDir, 0777) || &PrintErr("NoDirCreate", $InstallDir);
  185.     }
  186. }
  187. #if ($request =~ /^TESTDRIVE$/) {
  188. if ($request =~ /^(TESTDRIVE|DEMO|INSTALL)=/) {
  189.     #print "request TESTDRIVE=$request.<br>";
  190.     &CreateFiles($request);
  191. } elsif ($request =~ /^(TESTDRIVE|DEMO|INSTALL)$/) {
  192.     #print "request TESTDRIVE=$request.<br>";
  193.     &AskFileName($request);
  194. #elsif ($request eq "DEMO") {
  195. #elsif ($request eq "INSTALL") {
  196. }
  197.  
  198. if ($request =~ /textedit=/ ) {
  199.     $ScriptName = $request;
  200.     $ScriptName =~ s/textedit=//;
  201.     #unless (fork) {
  202.         #exec ("textedit $ScriptName");
  203.     #}
  204.     system ("textedit $ScriptName&");
  205.     $request = "";
  206. }
  207.  
  208. if ($request eq "") {
  209.         print "<IMG src=\"http://localhost:5759/DEV/images/finger.gif\">Please copy all the necessary files under the \"$HomeDir/_install\" directory<br>";
  210.     if ($Platform =~ /demo/ ) {
  211.         print "<h2><IMG src=\"http://localhost:5759/DEV/images/bullet_ball_red.gif\"><a href=\"http://localhost:5759/cgi-bin/addshow.pl?DEMO\">To include a slide-show about your product</a></h2><br>";
  212.         &OffersEditScript("DEMO");
  213.     }
  214.     if ($Platform =~ /testdrive/ ) {
  215.         print "<h2><IMG src=\"http://localhost:5759/DEV/images/bullet_ball_red.gif\"><a href=\"http://localhost:5759/cgi-bin/addshow.pl?TESTDRIVE\">To include a demo of your product</a></h2><br>";
  216.         &OffersEditScript("TESTDRIVE");
  217.     $~ = FOOTER;
  218.     }
  219.     if ($Platform =~ /install/ ) {
  220.         print "<h2><IMG src=\"http://localhost:5759/DEV/images/bullet_ball_red.gif\"><a href=\"http://localhost:5759/cgi-bin/addshow.pl?INSTALL\">To include an unlockable or light version of your product</a></h2><br>";
  221.         &OffersEditScript("INSTALL");
  222.     }
  223.     print "<h2><IMG src=\"http://localhost:5759/DEV/images/bullet_ball_red.gif\"><a href=\"http://localhost:5759/cgi-bin/mainmenu.pl?\">To go back to the main menu</a></h2><br>";
  224.  
  225.     select(STDOUT);
  226.     $~ = FOOTER;
  227.     write;
  228. }
  229.  
  230. #############################################################################
  231. # formats
  232. #############################################################################
  233. format HEADER =
  234. Content-type: text/html
  235.  
  236.  
  237. <html>
  238. <title>Developer's Kit</title>
  239. <body>
  240. <h1>CDware Developer's Kit</h1>
  241. <h4>Currently working with "@*
  242. $HomeDir
  243. "</h4>
  244. <ul type=1>
  245. .
  246.  
  247. format FOOTER =
  248. </ul>
  249. <p>
  250. <hr>
  251. #<p>
  252. #You, like these companies, will benefit from the CDware capability of reaching tens of thousands of potential customers with information, links to your web site, or directly with YOUR product!
  253. #<p><applet class=ImageTape width=596 height=65 img_dir=../../../DEV/logos speed=10 dir=-10
  254. #url1=oracle
  255. #url2=progress
  256. #url3=gupta
  257. #url4=informix
  258. #url5=lotus
  259. #url6=ingres
  260. #>
  261. </b>
  262. <h5><p><A HREF=http://localhost:5759/CDware/Help/SMICopyright.html>Copyright</A> 1995 Sun Microsystems, Inc., 2550 Garcia Ave., Mtn. View, CA 94043 USA.  All rights reserved.</h5><br></pre>
  263. <a href=http://localhost:5759/DEV/credits.html>Credits</a>
  264. </b>
  265. </form>
  266. </body>
  267. </html>
  268. .
  269.  
  270. format SHELL_FILE =
  271.  #! /bin/sh
  272.  #
  273.  #       get installation directory
  274.  #
  275.  
  276. # currently company dir is manually placed-should change
  277.  
  278. COMPANY_DIR=$PRODUCT_DIR/@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  279. $ShortHomeDir
  280. export COMPANY_DIR
  281.  
  282.  #
  283.  # execute installation script
  284.  #
  285.  
  286. $OPENWINHOME/bin/cmdtool -Wb 250 250 210 -Wl "@<<<<<<<<<<<<<<<<<<<<<" -Wx large -Ww 78 -Wh 20 -Wp 210 210 $COMPANY_DIR/_install/@*
  287. $WindowTitle{$request}, $rqpairs{$request}
  288.  
  289. read answer
  290. exit 0
  291. .
  292.  
  293. format INSTALL_INFO =
  294. <FORM method="post"  ACTION="http://localhost:5759/cgi-bin/addshow.pl?@*
  295. $request
  296. "> <INPUT TYPE="text" 
  297. ~@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  298. $Dir
  299.  NAME="IsIndex" SIZE="35" MAXLENGTH=50>
  300. <input type="submit" VALUE="Create File" >
  301. </FORM>
  302. .
  303.  
  304. format DEFAULT_INST_SCRIPT =
  305.  #! /bin/sh  
  306.  #
  307.  #    Installation shell script for Catalyst CDware
  308.  #
  309.  #     Usage: install_unbundled -m<mountpoint> -p<productpath>
  310.  #
  311.  #    Created:     June 12, 1991
  312.  #    Last Revised:     May 23, 1995
  313.  #
  314.  #    Use this installation script to install your product from Catalyst CDware
  315.  #
  316.  #
  317.  #    For technical support, please call.
  318.  #        +1 415 336.3742 (CDware SPARC) or +1 415 336.3941 (CDware x86)
  319.  #
  320.  #    get command line parameters
  321.  #
  322.  
  323.  # function for error exiting
  324.  
  325. end_it () {
  326.     echo " "
  327.     echo "Hit return to end ... "
  328.     read answer
  329.     exit 0
  330. }
  331.  
  332.  ###############################################################################
  333.  ###############################################################################
  334.  #    set PRODUCT_SIZE to the size of your product in kbytes     
  335.  ###############################################################################
  336. PRODUCT_SIZE=8000
  337.  ###############################################################################
  338.  #
  339.  #    get complete paths
  340.  #
  341.  #
  342.  #    get location of installation directory 
  343.  ##
  344. echo
  345. echo "Please enter the absolute path name of the directory structure in which"
  346. echo "you would like to install the demonstration and evaluation programs."
  347. echo
  348. echo "Installation directory: "
  349. read INSTALL_DIR
  350.  
  351.  #
  352.  #    verify the installation directory exists and is a directory
  353.  #
  354. if [ ! -d "$INSTALL_DIR" ]
  355. then
  356.     echo "Creating $INSTALL_DIR ..."
  357.     mkdir $INSTALL_DIR
  358.     if [ ! -d "$INSTALL_DIR" ]
  359.     then
  360.         echo
  361.         echo
  362.         echo "Could not create the installation directory."
  363.         echo
  364.         echo "Exiting the installation script."
  365.                 end_it
  366.     fi
  367. fi
  368.  
  369.  #
  370.  #    verify write permission for the installation directory
  371.  #
  372. if [ ! -w "$INSTALL_DIR" ]
  373. then
  374.     echo
  375.     echo
  376.     echo "You do not have write permission for the installation directory: "
  377.     echo $INSTALL_DIR
  378.     echo
  379.         echo
  380.     echo "Exiting the installation script."
  381.         end_it
  382. fi
  383.  
  384.  #
  385.  #    verify free disk space
  386.  #
  387. echo    
  388. echo    "Verifying free disk space..."
  389. FREE_SPACE=0
  390. df=/tmp/FREE.$$
  391.  #
  392.  # WARNING:
  393.  # --------
  394.  # For Solaris 2.4, the df line below will need to be updated because
  395.  # the standard output of the df command has changed in Solaris 2.4
  396.  #
  397. /usr/bin/df -k $INSTALL_DIR | sed /kbytes/d | sed -e '3,$d' | sed -e '1,$s/  */ /g' > $df
  398.  
  399. case `wc -l $df | sed -e 's/@ *//' | cut -f1 -d" " ` in
  400. "^"
  401.     1) FREE_SPACE=`cat $df | cut -f4 -d" "` ;; 
  402.     2) FREE_SPACE=`cat $df | sed 1d | sed 's/@ *//' | cut -f3 -d" "` ;; 
  403. "^"
  404. esac
  405.  
  406. if [ -n $FREE_SPACE ]
  407. then
  408.     if [ $FREE_SPACE -lt $PRODUCT_SIZE ]
  409.     then
  410.         echo
  411.         echo
  412.         echo "The product installation requires $PRODUCT_SIZE kbytes of"
  413.         echo "free disk space. There is only $FREE_SPACE kbytes of free" 
  414.         echo "disk space in the selected filesystem.  Please free up some"
  415.         echo "disk space and try this installation again."
  416.         echo
  417.         echo "Exiting the installation script."
  418.             end_it     
  419.     fi
  420. fi
  421. /bin/rm $df 2>/dev/null
  422.  
  423.  #
  424.  #    copy binaries to installation directory
  425.  #
  426. echo 
  427. echo "Copying files to "$INSTALL_DIR"..."
  428. echo
  429.  #
  430.  ###############################################################################
  431.  ###############################################################################
  432.  # uncomment the following line to do the actual copy
  433.  # this assumes that your files are tared and compressed
  434.  ###############################################################################
  435.  
  436.  #if [ $CDWARE_ENV != "Solaris_2" ]; then
  437.  
  438.  #    cd $INSTALL_DIR
  439.  #    zcat $COMPANY_DIR/_install/tarfileS2.Z | tar xf -
  440.  #else
  441.  #    if [ $CDWARE_ENV != "Solaris_1" ]; then
  442.  #        cd $INSTALL_DIR
  443.  #        zcat $COMPANY_DIR/_install/tarfileS2.Z | tar xf -
  444.  #    else
  445.  #        if [ $CDWARE_ENV != "Solaris_x86" ]; then
  446.  #            cd $INSTALL_DIR
  447.  #            zcat $COMPANY_DIR/_install/tarfileS2.Z | tar xf -
  448.  #        else
  449.  #            echo "This product doesn't run on this platform";
  450.  #        fi
  451.  #    fi
  452.  #fi
  453.  ###############################################################################
  454.  
  455. echo
  456. echo
  457. echo "To run our product, do the following: "
  458. echo
  459. echo "1. Change directories to "$INSTALL_DIR
  460. echo "2. Run the product by typing ./name_of_file"
  461. echo
  462. echo        
  463.  
  464.  
  465. end_it
  466. .
  467.  
  468. format DEFAULT_SHOW_SCRIPT=
  469.  #!/bin/sh
  470.  #       Installation shell script for Catalyst CDware
  471.  #
  472.  #       Usage: install_unbundled -m<mountpoint> -p<productpath>
  473.  #
  474.  #       Created:        June 12, 1991
  475.  #       Last Revised:   Dec 22, 1995
  476.  #
  477.  #       Use this installation script to install your product from Catalyst CDware
  478.  #
  479.  #
  480.  #       For technical support, please call.
  481.  #               +1 415 336.3742 (CDware SPARC) or +1 415 336.3941 (CDware x86)
  482.  #
  483.  #       get command line parameters
  484.  #
  485. echo ''
  486. echo '          Starting Slide Show...'
  487. LD_LIBRARY_PATH=$OPENWINHOME/lib
  488. export LD_LIBRARY_PATH
  489.  
  490.  ###############################################################################
  491.  ###############################################################################
  492.  # change these lines to start your slide-show
  493.  ###############################################################################
  494.  
  495. cd $COMPANY_DIR/_install/rolling/color
  496. /tmp/httpd/.cgi-bin/screendemo ./screendemo.menu
  497.  
  498.  ###############################################################################
  499. echo 'Press <Return> to close the window... '
  500. read answer
  501. exit 0
  502. .
  503.  
  504. format DEFAULT_RUN_SCRIPT =
  505.  #! /bin/sh 
  506.  #
  507.  #    Installation shell script for Catalyst CDware
  508.  #
  509.  #     Usage: install_unbundled -m<mountpoint> -p<productpath>
  510.  #
  511.  #    Created:     June 12, 1991
  512.  #    Last Revised:     May 23, 1994
  513.  #
  514.  #    Use this installation script to install your product from Catalyst CDware
  515.  #
  516.  #
  517.  #    For technical support, please call.
  518.  #        +1 415 336.3742 (CDware SPARC) or +1 415 336.3941 (CDware x86)
  519.  #
  520.  #    get command line parameters
  521.  #
  522. echo ' '
  523.  #if [ $CDWARE_ENV != "Solaris_2" ]; then
  524.  #    echo 'Starting XXX for Solaris 2.4'
  525.  #    run product for Solaris 2
  526.  #else
  527.  #    if [ $CDWARE_ENV != "Solaris_1" ]; then
  528.  #        run product for SunOs4
  529.  #    else
  530.  #        if [ $CDWARE_ENV != "Solaris_x86" ]; then
  531.  #            run product for Solaris x86
  532.  #        else
  533.  #            echo "This product doesn't run on this platform";
  534.  #        fi
  535.  #    fi
  536.  #fi
  537. echo ' '
  538. echo 'Press <Return> to close the window... '
  539. read answer
  540. exit 0;
  541. .
  542.